<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="./../home.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:pe="http://primefaces.org/ui/extensions">
    <ui:define name="content" >
        <div class="col-lg-12">
            <h3 class="page-header" id="comercio">
                Administracion de 
                <h:outputText value="Donantes de Canes" style="color:#00BFFF;" />
                <h:link value="Regresar a Listado" outcome="list.xhtml" styleClass="pull-right" style="font-size: 16px; margin-right: 30px;"  />
            </h3>
        </div>

        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-primary">
                    <h:messages id="msg" globalOnly="true" styleClass="list-group" infoClass="list-group-item list-group-item-success"
                                errorClass="list-group-item list-group-item-danger" />
                    <div class="panel-heading" style="font-weight: bold;" >Actualizar Donante</div>
                    <div class="panel-body">
                        <div class="row" id="modificarComercio">
                            <div class="col-lg-8 col-lg-offset-1">
                                <h:form id="frmRegistrarUser" styleClass="form-horizontal" >
                                    <f:event type="preRenderView" listener="#{donanteBean.initUpdate}" />
                                    <div class="form-group has-feedback">
                                        <label for="nombre" class="col-sm-5 control-label" style="text-align: right;">Nombre :</label>
                                        <div class="col-sm-5">
                                            <p:inputText styleClass="form-control" id="nombre" value="#{donanteBean.amo.nombre}" />
                                        </div>						    
                                    </div>
                                    <div class="form-group has-feedback">
                                        <label for="color" class="col-sm-5 control-label" style="text-align: right;">Apellidos :</label>
                                        <div class="col-sm-5">
                                            <p:inputText styleClass="form-control" id="color" value="#{donanteBean.amo.apellido}" />
                                        </div>						

                                    </div>
                                    <div class="form-group has-feedback">
                                        <label for="dni" class="col-sm-5 control-label" style="text-align: right;">DNI del Donante :</label>
                                        <div class="col-sm-5">
                                            <p:inputMask id="dni" styleClass="form-control" value="#{donanteBean.amo.dni}" mask="9?9999999" placeHolder="" />
                                        </div>						
                                    </div>
                                    <div class="form-group has-feedback">
                                        <label for="telf" class="col-sm-5 control-label" style="text-align: right;">Teléfono :</label>
                                        <div class="col-sm-5">
                                            <p:inputMask id="telf" styleClass="form-control" value="#{donanteBean.amo.telefono}" mask="9?999999" placeHolder="" />
                                        </div>						
                                    </div>
                                    <div class="form-group has-feedback">
                                        <label for="cel" class="col-sm-5 control-label" style="text-align: right;">Celular :</label>
                                        <div class="col-sm-5">
                                            <p:inputMask id="cel" styleClass="form-control" value="#{donanteBean.amo.celular}" mask="9?99999999" placeHolder="" />
                                        </div>						
                                    </div>
                                    <div class="form-group has-feedback">
                                        <label for="depar" class="col-sm-5 control-label" style="text-align: right;">Departamento :</label>
                                        <div class="col-sm-6">
                                            <p:selectOneMenu id="depar" value="#{donanteBean.idDepartamento}" style="width: 100%;" >
                                                <f:selectItems value="#{donanteBean.departamentos}" var="list" itemLabel="#{list.label}" itemValue="#{list.value}" >

                                                </f:selectItems>
                                                <f:ajax  event="change" render="prov dist" listener="#{donanteBean.cambiarDepartamentos}" />
                                            </p:selectOneMenu>
                                        </div>						
                                    </div>

                                    <div class="form-group has-feedback">
                                        <label for="prov" class="col-sm-5 control-label" style="text-align: right;">Provincia :</label>
                                        <div class="col-sm-6">
                                            <p:selectOneMenu id="prov" value="#{donanteBean.idProvincia}" style="width: 100%;" >
                                                <f:selectItems value="#{donanteBean.provincias}" var="list" itemLabel="#{list.label}" itemValue="#{list.value}" />
                                                <f:ajax event="change" render="dist" listener="#{donanteBean.cambiarProvincias}"  />
                                            </p:selectOneMenu>

                                        </div>						
                                    </div>

                                    <div class="form-group has-feedback">
                                        <label for="dist" class="col-sm-5 control-label" style="text-align: right;">Distrito :</label>
                                        <div class="col-sm-6">
                                            <p:selectOneMenu id="dist" value="#{donanteBean.idDistrito}" style="width: 100%;" >
                                                <f:selectItems value="#{donanteBean.distritos}" var="list" itemLabel="#{list.label}" itemValue="#{list.value}" />
                                            </p:selectOneMenu>
                                        </div>						
                                    </div>

                                    <div class="form-group has-feedback">
                                        <label for="direc" class="col-sm-5 control-label" style="text-align: right;">Dirección :</label>
                                        <div class="col-sm-5">
                                            <p:inputText styleClass="form-control" id="direc" value="#{donanteBean.amo.direccion}" />
                                        </div>						
                                    </div>



                                    <p:commandButton value="Guardar" styleClass="btn btn-primary" actionListener="#{donanteBean.actualizarAmo}" onstart="PF('blockUIWidget').block()"
                                                     oncomplete="PF('blockUIWidget').unblock();subir();" update="@form :msg" />
                                    <pe:blockUI   widgetVar="blockUIWidget">  
                                        <h:panelGrid columns="2">  
                                            <h:graphicImage library="image" name="cargar.gif"  
                                                            style="margin-right: 5px; vertical-align: middle;"/>  
                                            <h:outputText value="Espere ..." style="white-space: nowrap;"/>  
                                        </h:panelGrid>  
                                    </pe:blockUI>  
                                </h:form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script>
            function subir() {
                window.scrollTo(0, 0);
            }
        </script>
    </ui:define>


</ui:composition>

